package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldClasses;
import com.cleaningcloud.cld.service.ICldClassesService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 班次管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-19
 */
@RestController
@RequestMapping("/classes")
public class CldClassesController extends BaseController
{
    @Autowired
    private ICldClassesService cldClassesService;

    /**
     * 查询班次管理列表
     */
    @RequiresPermissions("cld:classes:list")
    @GetMapping("/list")
    public TableDataInfo list(CldClasses cldClasses)
    {
        startPage();
        List<CldClasses> list = cldClassesService.selectCldClassesList(cldClasses);
        return getDataTable(list);
    }

    /**
     * 导出班次管理列表
     */
    @RequiresPermissions("cld:classes:export")
    @Log(title = "班次管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldClasses cldClasses)
    {
        List<CldClasses> list = cldClassesService.selectCldClassesList(cldClasses);
        ExcelUtil<CldClasses> util = new ExcelUtil<CldClasses>(CldClasses.class);
        util.exportExcel(response, list, "班次管理数据");
    }


    /**
     * 获取班次列表
     */
    @GetMapping("/getList")
    public AjaxResult getList()
    {
        return success(cldClassesService.getList());
    }


    /**
     * 获取班次管理详细信息
     */
    @RequiresPermissions("cld:classes:query")
    @GetMapping(value = "/{classesId}")
    public AjaxResult getInfo(@PathVariable("classesId") Long classesId)
    {
        return success(cldClassesService.selectCldClassesByClassesId(classesId));
    }

    /**
     * 新增班次管理
     */
    @RequiresPermissions("cld:classes:add")
    @Log(title = "班次管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldClasses cldClasses)
    {
        return toAjax(cldClassesService.insertCldClasses(cldClasses));
    }

    /**
     * 修改班次管理
     */
    @RequiresPermissions("cld:classes:edit")
    @Log(title = "班次管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldClasses cldClasses)
    {
        return toAjax(cldClassesService.updateCldClasses(cldClasses));
    }

    /**
     * 删除班次管理
     */
    @RequiresPermissions("cld:classes:remove")
    @Log(title = "班次管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classesIds}")
    public AjaxResult remove(@PathVariable Long[] classesIds)
    {
        return toAjax(cldClassesService.deleteCldClassesByClassesIds(classesIds));
    }
}
